package com.youlu.campus.admin.sign;

import com.youlu.campus.admin.sign.service.SignPlanService;
import com.youlu.campus.base.base.PageQueryRequest;
import com.youlu.campus.base.sign.dto.SignDailyPageRequest;
import com.youlu.campus.base.sign.dto.SignPlanCreateRequest;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SignPlanController {

    @Autowired
    private SignPlanService signPlanService;

    /**
     * 打卡项目列表
     *
     * @param request
     * @return
     */
    @PostMapping("/sign-plan/page")
    public QResult signPlanpage(@RequestBody PageQueryRequest request) {
        return signPlanService.getSignPlanList(request);
    }

    /**
     * 新增打卡项目
     *
     * @param createRequest
     * @return
     */
    @PostMapping("/sign-plan/create")
    public QResult createSignPlan(@RequestBody SignPlanCreateRequest createRequest) {
        return signPlanService.createSignPlan(createRequest);
    }

    /**
     * 编辑打卡项目
     *
     * @param createRequest
     * @return
     */
    @PostMapping("/sign-plan/edit")
    public QResult editSignPlan(@RequestBody SignPlanCreateRequest createRequest) {
        return signPlanService.editSignPlan(createRequest);
    }

    /**
     * 更改打卡项目状态
     *
     * @param id
     * @param status
     * @return
     */
    @PostMapping("/sign-plan/status")
    public QResult signPlanStatus(String id, String status) {
        QResult<Integer> result = signPlanService.signPlanStatus(id, status);
        return result;
    }

    /**
     * 打卡内容列表
     *
     * @param request
     * @return
     */
    @PostMapping("/sign-daily/page")
    public QResult getSignDailyList(@RequestBody SignDailyPageRequest request) {
        return signPlanService.getSignDailyList(request);
    }

    /**
     * 更改打卡项目状态
     *
     * @param id
     * @param displayed
     * @return
     */
    @PostMapping("/sign-daily/status")
    public QResult SignDailyDisplayed(String id, boolean displayed) {
        QResult<Integer> result = signPlanService.SignDailyDisplayed(id, displayed);
        return result;
    }
}
